
<?php	
	
	class page extends database
	{
		var $connection = '';	

		function page()
		{
			parent::database();
		}
	
		function GetListPaging()
		{						
			$this->setQuery("set names utf8");
			$this->query();
			return $sql = "Select * from tblpage";			
			//return $pager;
			//$rs = $pager->paginate();
	//Loop through the result set
				
			/*$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;*/
		}
		
		function GetList()
		{						
			$this->setQuery("set names utf8");
			$this->query();			
			$sql = "SELECT p.*, d.* from tblpage p
             INNER JOIN tblDepartment d ON p.DepartmentID = d.DepartmentID ";			
			$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;
		}
        
        function AddPage($DepartmentID, $Title, $Link, $Picture, $Description, $FeaturedYN, $SortPriority, $ActiveYN)
		{
            $DateSubmit=date('Y-m-d H:i:s', time());
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Insert into tblpage(`DepartmentID`, `Title`, `Link`, `Picture`
            , `Description`, `FeaturedYN`, `SortPriority`, `ActiveYN`) 
            values('".$DepartmentID."', '".$Title."', '".$Link."', '".$Picture."', '".$Description."'
            , '".$FeaturedYN."', '".$SortPriority."', '".$ActiveYN."')";
            //echo $sql;
			$this->setQuery($sql);
			$this->query();
		}
		
		function UpdatePage($DepartmentID, $Title, $Link, $Picture, $Description, $FeaturedYN, $SortPriority, $ActiveYN, $id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Update tblpage set `DepartmentID` =  '".$DepartmentID."', 
            `Title` = '".$Title."', `Link` = '".$Link."', 
            `Picture` = '".$Picture."', `Description` = '".$Description."',`FeaturedYN` = '".$FeaturedYN."',`SortPriority` = '".$SortPriority."', 
            `ActiveYN` = '".$ActiveYN."'";
			$sql .= " where PageID=".$id;	
            //echo $sql;		
			$this->setQuery($sql);
			$this->query();
		}
		
		function GetOnePage($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Select * from tblpage where PageID=".$id."";
			$this->setQuery($sql);
			$row = $this->loadOneRow();
			return $row;
		}
		
		function DeletePage($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Delete from tblpage ";
			$sql .= " where PageID=".$id;			
			$this->setQuery($sql);
			$this->query();
		}
	
		
	}
?>